﻿#pragma once
#include "yzrutil.h"
#include "DSPGroup.h"

namespace yzrilyzr_dsp{
	ECLASS(DSPChain, public DSPGroup){
	public:
	u_sample procDsp(u_sample v) override{
		for(auto & d : dsps){
			if(d == nullptr) continue;
			v=d->procDsp(v);
		}
		return v;
	}
	void procBlock(u_sample * input, u_sample * output, u_index length)override{
		for(auto & d : dsps){
			if(d == nullptr) continue;
			d->procBlock(input, output, length);
		}
	}
	DSPChain() :DSPGroup(){}
	DSPChain(std::vector<std::shared_ptr<DSP>> &dsps1):DSPGroup(dsps1){	}
	std::shared_ptr<DSP> cloneDSP()override{
		std::vector<std::shared_ptr<DSP>> dsps1;
		for(auto & d : dsps){
			dsps1.push_back(std::shared_ptr<DSP>(d->cloneDSP()));
		}
		return std::make_shared < DSPChain>(dsps1);
	}
	yzrilyzr_lang::String toString()const override;
	};
}